





//
//  NFeedbackPop.m
//  nncloud
//
//  Created by macfai on 2018/9/29.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NFeedbackPop.h"
#import "UITextView+PlaceHolder.h"

#define kViewHeight 230

@interface NFeedbackPop()

@property(nonatomic,strong)UIView *bottomBgView;

@end

@implementation NFeedbackPop


- (instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        //        self.frame = frame;
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.5];
        [self setUI];
    }
    return self;
}

- (void)setUI {
    
    self.bottomBgView = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth, kViewHeight)];
    self.bottomBgView.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0];
    [self addSubview:self.bottomBgView];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 8, ScreenWidth, 40)];
    label.centerX = self.centerX;
    label.text =@"重新发起问题反馈";
//    label.numberOfLines = 0;
    label.textColor = [UIColor darkGrayColor];
    label.font = [UIFont systemFontOfSize:20];
    //    label.backgroundColor = [UIColor magentaColor];
    
    label.textAlignment = NSTextAlignmentCenter;
    [self.bottomBgView addSubview:label];
    
    //线条
    UIView *line = [UIView new];
    line.frame = CGRectMake(0, label.bottom+5, ScreenWidth, 0.5);
    line.backgroundColor = kDarkGrayColor;
    [self.bottomBgView addSubview:line];
    
    UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, line.bottom+1, ScreenWidth, 130)];
    textView.placeholder = @"请输入反馈内容";
    [self.bottomBgView addSubview:textView];
    
    UIView *line1 = [UIView new];
    line1.frame = CGRectMake(0, textView.bottom+1, ScreenWidth, 0.5);
    line1.backgroundColor = kDarkGrayColor;
    [self.bottomBgView addSubview:line1];
    
    
    
    
}




-(void)show{

    [[UIApplication sharedApplication].keyWindow addSubview:self];
    [UIView animateWithDuration:.3 animations:^{
        if (ScreenWidth>320) {
            self.bottomBgView.transform = CGAffineTransformMakeTranslation(0,  - kViewHeight);
        }else{
            self.bottomBgView.transform=  CGAffineTransformMakeTranslation(0, -160);
        }
        
    }];
}

-(void)dismiss{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.bottomBgView.transform = CGAffineTransformIdentity;
        
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [super touchesBegan:touches withEvent:event];
    [self dismiss];
}



@end
